package game.snake.direction;
import game.Field;
import game.Point;
import game.snake.Snake;
import game.snake.SnakeBody;


/**
 * The right direction of the snake.
 * 
 * @author Sarun Wongtanakarn 5510546166
 * @author Apiwat Jierakulpanit 5510546212
 * @Version 2013.05.01
 */
public class DirectionRight extends Direction{

	public DirectionRight(Snake snake) {
		super(snake);
	}

	@Override
	public void changeDirection(Direction direction) {
		if(!(direction instanceof DirectionLeft))
			snake.setDirection(direction);
		snake.getHead().setDirection(direction);
	}

	@Override
	public void move(SnakeBody blockBody, Field field) {
		int newX = blockBody.getPoint().X + 1;
		if(newX > field.getWidth()-1)
			newX = 0;
		blockBody.setPoint(field.POINT[newX][blockBody.getPoint().Y]);
		
	}

	@Override
	public void growth(Point[][] point) {
		snake.getBody().add(new SnakeBody( point[snake.getTail().getPoint().X - 1][snake.getTail().getPoint().Y] , snake.getTail().getDirection() ));
		
	}

}
